﻿<StackPanel
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dataform="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit"
    xmlns:local="clr-namespace:CoProjectDF.Controls"
    xmlns:login="clr-namespace:CoProjectDF.Views.Login"
    x:Class="CoProjectDF.Views.Login.RegistrationForm"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d"
    d:DataContext="{d:DesignInstance login:RegistrationViewModel, IsDesignTimeCreatable=True}">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <local:BusyIndicator x:Name="busyIndicator" BusyContent="{Binding Path=ApplicationStrings.BusyIndicatorRegisteringUser, Source={StaticResource ResourceWrapper}}"
                             IsBusy="{Binding IsRegistering}">

            <local:CustomDataForm x:Name="registerForm" 
                                  Padding="10,10,20,0"
                                  CurrentItem="{Binding RegistrationData}"
                                  IsEnabled="{Binding CanRegister}" 
                                  AutoEdit="True" CommandButtonsVisibility="None"  
                                  Header="{Binding Path=ApplicationStrings.RegistrationFormHeader, Source={StaticResource ResourceWrapper}}" 
                                  AutoGeneratingField="RegisterForm_AutoGeneratingField"
                                  Style="{StaticResource DataFormStyle}" />
            
        </local:BusyIndicator>

        <StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,10,0">
            <Button x:Name="registerButton" Content="{Binding Path=ApplicationStrings.OKButton, Source={StaticResource ResourceWrapper}}" Click="RegisterButton_Click" Style="{StaticResource RegisterLoginButtonStyle}" IsEnabled="{Binding CanRegister}" />
            <Button x:Name="registerCancel" Content="{Binding Path=ApplicationStrings.CancelButton, Source={StaticResource ResourceWrapper}}" Click="CancelButton_Click" Style="{StaticResource RegisterLoginButtonStyle}" />
        </StackPanel>

        <StackPanel Style="{StaticResource RegisterLoginLinkPanelStyle}" Grid.Row="1">
            <TextBlock Text="{Binding Path=ApplicationStrings.AlreadyRegisteredLabel, Source={StaticResource ResourceWrapper}}" Style="{StaticResource CommentStyle}" />
            <HyperlinkButton x:Name="backToLogin" Content="{Binding Path=ApplicationStrings.BackToLoginButton, Source={StaticResource ResourceWrapper}}" Click="BackToLogin_Click" IsEnabled="{Binding IsRegistering, Converter={StaticResource NotOperatorValueConverter}}" />
        </StackPanel>
    </Grid>

</StackPanel>
